package dim

import java.nio.charset.Charset
import java.util

import org.apache.hadoop.conf
import org.apache.hadoop.hbase.{Cell, HBaseConfiguration, TableName}
import org.apache.hadoop.hbase.client.{Connection, ConnectionFactory, Result, ResultScanner, Scan, Table}
import org.apache.hadoop.hbase.util.Bytes

object Test {
  def main(args: Array[String]): Unit = {
    val tName = "lagou_area"
    val family = "f1"

    val configuration: conf.Configuration = HBaseConfiguration.create()
    configuration.set("hbase.zookeeper.quorum","linux100")
    configuration.set("hbase.zookeeper.property.clientPort","2181")
    val connection: Connection = ConnectionFactory.createConnection(configuration)
    val table: Table = connection.getTable(TableName.valueOf(tName))
    val scan = new Scan()
    scan.addFamily(family.getBytes(Charset.forName("UTF-8")))

    val rs: ResultScanner = table.getScanner(scan)
    val iterator: util.Iterator[Result] = rs.iterator()
    while (iterator.hasNext) {
      val result: Result = iterator.next()
      val rowKey: String = Bytes.toString(result.getRow)
      val cells: util.List[Cell] = result.listCells()
      val stringBuilder = new StringBuilder
      cells.forEach((cell: Cell) => {
        stringBuilder.append(Bytes.toString(cell.getValueArray, cell.getValueOffset, cell.getValueLength)).append("-")
      })




    }
  }
}
